<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>验收单</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/lodop/LodopFuncs.js" type="text/javascript"></script>
    <script>
        function exportExcel() {
            parent.$.jBox.confirm("确认要导出总括帐吗？", "系统提示", function (v, h, f) {
                if (v == "ok") {
                    $("#searchForm").attr("action", "${ctx}/book/store/exportGeneralLedger").submit();
                }
            });
        }
        function searchLedger() {
            $("#searchForm").attr("action", "${ctx}/book/store/generalLedger").submit();
        }
    </script>
</head>
<body>
<form:form id="searchForm" action="${ctx}/book/store/generalLedger" method="post" class="breadcrumb form-search">
    <label>条形码范围：</label><input name="begin" value="${begin}" type="text" maxlength="20" class="input-small"/>
    —&nbsp;<input name="end" value="${end}" type="text" maxlength="20" class="input-small"/>&nbsp;

    <label>批次编号：</label>
    <select name="batchNumber" style="width: 140px;">
        <option value="">请选择</option>
        <c:forEach items="${all}" var="batch">
            <option value="${batch.batchNumber}" ${batch.remarks}>${batch.batchNumber}</option>
        </c:forEach>
    </select>

    <a id="btnSubmit" href="javascript:void(0)" onclick="searchLedger()" class="btn">查询</a>&nbsp;&nbsp;
    <a id="btnPrint" href="javascript:void(0)" onclick="print()" class="btn">打印</a>&nbsp;&nbsp;
    <a id="btnExport" href="javascript:void(0)" onclick="exportExcel()" class="btn">导出Excel</a>
</form:form>
<div id="ledgerContent">
    <style type="text/css" scoped>
        .table-bordered th, .table-bordered td { border-left: 1px solid #ddd; } .table th, .table td { line-height: 20px; text-align: left; border-top: 1px solid #ddd; } .table-bordered { border: 1px solid #ddd; border-collapse: separate; border-left: 0; border-radius: 4px; }
    </style>
    <div style="width: 800px;">
        <div style="width: 100%;text-align: center">
            <h3>总括财产帐</h3>
        </div>
        <div style="width: 100%;text-align: left;">
            <c:if test="${begin != '' || end != ''}">
                【条形码范围：${begin}&nbsp;&nbsp;&nbsp;&nbsp;——&nbsp;&nbsp;&nbsp;&nbsp;${end}】
            </c:if>
            <c:if test="${batchNumber != ''}">
                【批次编号：${batchNumber}】
            </c:if>
        </div>
        <c:set var="typeAmount" value="0"/>
        <c:set var="bookAmount" value="0"/>
        <c:set var="totalPrice" value="0"/>
        <table id="contentTable" style="width: 100%;" class="table table-striped table-bordered table-condensed">
            <tr>
                <th style="width:20px;">序号</th>
                <th style="width:220px;">索书号</th>
                <th style="width:120px;">种数</th>
                <th style="width:120px;">册数</th>
                <th style="width:120px;">单价和</th>
            </tr>
            <c:forEach items="${generalledger}" var="r" varStatus="status">
                <tr>
                    <td>
                        <div style="width:20px;">${status.count}</div>
                    </td>
                    <td>
                            ${r.classcode}|${r.className}
                    </td>
                    <td style="text-align:right;width:120px;">
                            ${r.count}
                    </td>
                    <td style="text-align:right;width:120px;">
                            ${r.amount}
                    </td>
                    <td style="text-align:right;width:120px;">
                            <fmt:formatNumber type="number" value="${r.total}" pattern="0.00" maxFractionDigits="2"/>
                    </td>
                </tr>
                <c:set value="${typeAmount + r.count}" var="typeAmount"/>
                <c:set value="${bookAmount + r.amount}" var="bookAmount"/>
                <c:set value="${totalPrice + r.total}" var="totalPrice"/>
            </c:forEach>
            <tr>
                <td>合计：</td>
                <td style="text-align:right;"></td>
                <td style="text-align:right;">${typeAmount}</td>
                <td style="text-align:right;">${bookAmount}</td>
                <td style="text-align:right;">
                    <fmt:formatNumber type="number" value="${totalPrice}" pattern="0.00" maxFractionDigits="2"/>
                </td>
            </tr>
        </table>
    </div>
</div>
<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <param name="Border" value="1">
    <param name="Color" value="white">
    <embed id="LODOP_EM" TYPE="application/x-print-lodop" width=0 height=0 border=0 Color="white"
           PLUGINSPAGE="install_lodop.exe">
</object>
<script type="text/javascript">
    /**
     *  打印预览
     */
    //声明为全局变量
    var LODOP;
    function print() {
        LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("打印");
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");

        LODOP.ADD_PRINT_HTM(20, 20, 600, 800, $("#ledgerContent").html());
        LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT","Full-Width");//按整页缩放

        LODOP.PRINT_DESIGN();
        LODOP.SHOW_CHART();
    }
</script>
</body>
</html>